package com.jiangjiang.eshop.inventory.async;

import java.util.Observable;

/**
 * @ClassName StockUpdateObservable
 * @Description
 * @Author jhw
 * @Date 2021/6/14 15:35
 * @Version 1.0
 **/
public class StockUpdateObservable extends Observable {
    /**
     * 消息id
     */
    private String messageId;

    public StockUpdateObservable(String messageId) {
        this.messageId = messageId;
    }

    /**
     * 设置库存更新结果
     * @param result 库存更新结果
     */
    public void setResult(Boolean result){
        StockUpdateResult stockUpdateResult = new StockUpdateResult();
        stockUpdateResult.setMessageId(messageId);
        stockUpdateResult.setResult(result);

        this.setChanged();
        // 推模式
        this.notifyObservers(stockUpdateResult);

    }
}
